# Contributor: Mike Crute <mike@crute.us>
# Contributor: Jake Buchholz Göktürk <tomalok@gmail.com>
# Maintainer: Jake Buchholz Göktürk <tomalok@gmail.com>
pkgname=tiny-cloud
pkgver=3.0.4
pkgrel=2
pkgdesc="Tiny Cloud instance bootstrapper"
url="https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud"
arch="noarch"
license="MIT"
#_network_deps="ifupdown-ng iproute2-minimal"
_alpine_deps="ifupdown-ng"
#_aws_deps="nvme-cli"
_aws_deps="nvme-cli ifupdown-ng iproute2-minimal"
makedepends="$_alpine_deps $_aws_deps" # $_network_deps"
checkdepends="kyua xz lz4 zstd"
depends="e2fsprogs-extra partx sfdisk yx openssh-server"
source="
	https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud/-/archive/$pkgver/tiny-cloud-$pkgver.tar.gz
	0001-nocloud-support-set-data-source-via-smbios-in-qemu.patch

	tiny-cloud-alpine.post-install
	tiny-cloud-aws.post-install
	tiny-cloud-azure.post-install
	tiny-cloud-gcp.post-install
	tiny-cloud-nocloud.post-install
	tiny-cloud-oci.post-install
	tiny-cloud-openrc.pre-upgrade
	tiny-cloud.pre-upgrade
"
#	$pkgname-network
subpackages="
	$pkgname-openrc
	$pkgname-alpine
	$pkgname-aws
	$pkgname-azure
	$pkgname-gcp
	$pkgname-oci
	$pkgname-nocloud
"

check() {
	make check
}

package() {
	make PREFIX="$pkgdir" core openrc
	install="$pkgname.pre-upgrade"
}

openrc() {
	install="$pkgname-openrc.pre-upgrade"
	default_openrc
}

#network() {
#	pkgdesc="Tiny Cloud - networking module"
#	depends="$_network_deps $pkgname=$pkgver-r$pkgrel"
#	make -C "$builddir" PREFIX="$subpkgdir" network
#}

alpine() {
	pkgdesc="Tiny Cloud - Alpine installer module"
	depends="$_alpine_deps $pkgname-nocloud=$pkgver-r$pkgrel"
	install="$pkgname-alpine.post-install"
	make -C "$builddir" PREFIX="$subpkgdir" alpine
}

aws() {
	pkgdesc="Tiny Cloud - Amazon Web Services module"
	#depends="$_aws_deps $pkgname-network=$pkgver-r$pkgrel"
	depends="$_aws_deps $pkgname=$pkgver-r$pkgrel"
	provides="tiny-ec2-bootstrap"
	install="$pkgname-aws.post-install"
	make -C "$builddir" PREFIX="$subpkgdir" aws
}

azure() {
	pkgdesc="Tiny Cloud - Azure module"
	#depends="$pkgname-network=$pkgver-r$pkgrel"
	depends="$pkgname=$pkgver-r$pkgrel"
	install="$pkgname-azure.post-install"
	make -C "$builddir" PREFIX="$subpkgdir" azure
}

gcp() {
	pkgdesc="Tiny Cloud - Google Cloud Platform module"
	#depends="$pkgname-network=$pkgver-r$pkgrel"
	depends="$pkgname=$pkgver-r$pkgrel"
	install="$pkgname-gcp.post-install"
	make -C "$builddir" PREFIX="$subpkgdir" gcp
}

oci() {
	pkgdesc="Tiny Cloud - Oracle Cloud Infrastructure module"
	#depends="$pkgname-network=$pkgver-r$pkgrel"
	depends="$pkgname=$pkgver-r$pkgrel"
	install="$pkgname-oci.post-install"
	make -C "$builddir" PREFIX="$subpkgdir" oci
}

nocloud() {
	pkgdesc="Tiny Cloud - NoCloud module"
	depends="$pkgname=$pkgver-r$pkgrel"
	install="$pkgname-nocloud.post-install"
	make -C "$builddir" PREFIX="$subpkgdir" nocloud
}

sha512sums="
b6ca3ac4a3b5839679f44ffea0e0c819ad3e036b525a3e1eb2b138c08838d97babd12903f11d7b52007b2d9cace685909795bc2451a2f1cbd46dcafb51556021  tiny-cloud-3.0.4.tar.gz
750057fcea6d4364da002ff38c2ad8649325ac55b87ace498c007eb8e6dc8e2fb22eb630b9be9ac3831380091f688d6782f0a14e6eae36352941dfdfafdff654  0001-nocloud-support-set-data-source-via-smbios-in-qemu.patch
9d41eae6f1eb7addec7aa8dfd8ebe8a2522772ae438e46b773121e9c7d3b9806b5abbe2e249361160727b4b0ed63df21e7cbc50e21aaecd6544310836ee7757e  tiny-cloud-alpine.post-install
0165ac30c5e78448373f44d596930e68bdb8e4c9a10441f13b3ec44a879482eca2904b6a2a2702f2d66510a3cc58935ce373ce1fb5ae2fa786372883253f3245  tiny-cloud-aws.post-install
04752ec96f25dd5ceb7d8b7c63ac0e9f8f92fea675d115c24f0bebaa4cb16af147550f9d4c148e800273389da2c64e6304dc45333e25ae08d9aa4e33aff431c9  tiny-cloud-azure.post-install
05b7ccbb441f7635b13b1c81e8341e74cbf6cd158b257c9286d31ca736c45ef64ef2778990f57b3f880372b442e0a677e95a0fbe2ec357e89627363707089a7c  tiny-cloud-gcp.post-install
df4f37aa7c27d7f011ef2aa6e3c1d88d25c9e117df947bd238c1fc3aa9aef9e9d66af679bb9e2c58564cbc8fb5a1ec51827063a91c0a8cb4efc1a7563cc5a172  tiny-cloud-nocloud.post-install
e23482f9b6678a34c1ea98a55c76852e571f0c86717b26e449687e1691d4f00608a16e3f2a6119ee7d793c6853a3c4d4eac2e82a075ab0456d9f94f2e1110030  tiny-cloud-oci.post-install
a2f795c1d9cce1a796cc92711b18459706b6573417d2ef43504c50a65f4808eaf8f8d48a20a4f198ade25c285188659a95d51e5cb34e4c64cf6384459397b850  tiny-cloud-openrc.pre-upgrade
83217a30e495bcc18ad1a5d744806d499b5bdf929df3f18597216a25f465e5d4764ca66499d221bf5738b83639f1ec80de2a14e4b64aac80d51b285c01f0fc74  tiny-cloud.pre-upgrade
"
